package com.demo.common.core.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author MyPC
 */
@Data
public class SysUserBo {

    private Long userId;
    private String uk;
    private String spaceUrl;
    private String pk;
    private String mobile;
    private String mailbox;
    private String nickName;
    private String avatar;
    private String sex;
    private String registerType;
    private String addr;
    private String status;
    private String remark;

    /**
     * 部门对象
     */
    private SysDeptBo sysDeptBo;

    /**
     * 角色对象
     */
    private List<SysRoleBo> sysRoleBos;

    /**
     * 角色组
     */
    private Long[] roleIds;

    /**
     * 岗位组
     */
    private Long[] postIds;

    /**
     * 部门id
     */
    private Long deptId;

    /**
     * 最后登录的ip
     */
    private String loginIp;

    /**
     * 最后登录时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private Date loginDate;

    private String createBy;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private Date createTime;

    public List<SysRoleBo> getSysRoleBos() {
        return new ArrayList<>();
    }

    public void setSysRoleBos(List<SysRoleBo> sysRoleBos) {
        this.sysRoleBos = sysRoleBos;
    }

    public boolean isAdmin() {
        return isAdmin(this.userId);
    }

    public static boolean isAdmin(Long userId) {
        return userId != null && 8888888888888888L == userId;
    }
}